<%@ page import="entity.Book" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: LMY
  Date: 2025/6/21
  Time: 22:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
  <html>
  <head>
      <title>el表达式输出数据</title>
  </head>

  <body>
    <%
      //创建一个Book对象，放入相关属性
      Book book = new Book();
      book.setName("昆虫总动员");
      book.setWriter(new String[]{"jack", "tom"});
      ArrayList<String> list = new ArrayList<>();
      list.add("lmy");
      list.add("mary");
      book.setReaders(list);
      HashMap<String, String> map = new HashMap<>();
      map.put("topic1", "很不错...");
      map.put("topic2", "一般般...");
      book.setTopics(map);

      //把 book 放入 request 域对象
      request.setAttribute("bookKey", book);
    %>
  book对象：${bookKey}<br/>
  book.name= ${bookKey.name}<br/>
  book.writer= ${bookKey.writer}<br/>
  book.writer[0]= ${bookKey.writer[0]}<br/>
  book.readers= ${bookKey.readers}<br/>
  book.readers[1]= ${bookKey.readers.get(1)}<br/>
  book.topics= ${bookKey.topics}<br/>
  book.topics的第一个评论= ${bookKey.topics["topic1"]}
  </body>
</html>
